package com.ling.design;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Map;

/**
 * @author: ling007
 * @date: 2024/9/30 10:48
 * @description:
 */

public abstract class NetMall {

    protected Logger logger = LoggerFactory.getLogger(NetMall.class);


    String uId;   // ⽤用户ID
    String uPwd;  // ⽤用户密码

    public NetMall(String uId, String uPwd) {
        this.uId = uId;
        this.uPwd = uPwd;
    }

    /**
     * ⽣生成商品推⼴广海海报
     *
     * @param skuUrl 商品地址(京东、淘宝、当当)
     * @return 海海报图⽚片base64位信息
     */
    public String generateGoodsPoster(String skuUrl) {
        if (!login(uId, uPwd)) return null;// 1. 验证登录
        Map<String, String> reptile = reptile(skuUrl);  // 2. 爬⾍虫商品
        return createBase64(reptile);   // 3. 组装海海报
    }

    // 模拟登录
    protected abstract Boolean login(String uId, String uPwd);

    // 爬⾍虫提取商品信息(登录后的优惠价格)
    protected abstract Map<String, String> reptile(String skuUrl);

    // ⽣生成商品海海报信息
    protected abstract String createBase64(Map<String, String> goodsInfo);

}
